import {menuList, getAllMenuTreeList} from '../../assets/js/service.business';

export default {
    state: {
        menu: {},
        menuTree: {}
    },
    mutations: {
        set_menu: function (state, res) {
            state.menu = res;
        },
        set_menuTree: function (state, res) {
            state.menuTree = res;
        }
    },
    actions: {
        asyncGetmenuList: async function ({commit}, args) {
            let res = await menuList(args);
            if (res.code === 0) {
                commit('set_menu', res)
            } else {
                commit('set_menu', [])
            }
            return res;
        },
        asyncGetAllTreeList: async function ({commit}, args) {
            let res = await getAllMenuTreeList(args);
            if (res.code === 0) {
                commit('set_menuTree', res)
            } else {
                commit('set_menuTree', [])
            }
            return res;
        }
    }
};
